package com.qs.eggs.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.qs.eggs.R;
import com.shizhefei.view.indicator.FixedIndicatorView;
import com.shizhefei.view.indicator.IndicatorViewPager;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/5/3.
 */

public class EvaluationTabIndicatorAdapter extends IndicatorViewPager.IndicatorFragmentPagerAdapter {

    private String[] tabNameS;
    private LayoutInflater inflater;
    private ArrayList<Fragment>fmList;
    private FixedIndicatorView indicator;
    public static final int ACTION_UP=1;
    public static final int ACTION_DOWN=2;
    private Context mContext;
    public EvaluationTabIndicatorAdapter(FragmentManager fragmentManager) {
        super(fragmentManager);
    }

    public EvaluationTabIndicatorAdapter( FragmentManager fragmentManager, Context mContext, ArrayList<Fragment> fmList, String[]tabNameS) {
        super(fragmentManager);
        this.tabNameS=tabNameS;
        this.mContext=mContext;
        this.indicator=indicator;
        this.fmList=fmList;
        inflater = LayoutInflater.from(mContext);

    }

    @Override
    public int getCount() {
        return tabNameS.length;
    }

    @Override
    public View getViewForTab(int position, View convertView, ViewGroup container) {
        if (convertView == null) {

            convertView = inflater.inflate(R.layout.tab_guide_evaluation,
                    container, false);
        }
        TextView textView = (TextView) convertView.findViewById(R.id.tv_tab);
        TextView EvauCount = (TextView) convertView.findViewById(R.id.tv_count_evaluation);
        textView.setText(tabNameS[position]);
        if(position!=0){
            EvauCount.setVisibility(View.VISIBLE);
        }else {
            EvauCount.setVisibility(View.GONE);

        }

        return convertView;
    }

    @Override
    public Fragment getFragmentForPage(int position) {
        // 填充Fragment界面,需要与tab数量相等
        switch (position) {
            case 0:
                return fmList.get(position);

            case 1:
                return fmList.get(position);

            case 2:
                return fmList.get(position);

            case 3:
                return fmList.get(position);

            default:
                return null;

        }
    }
}
